import { request } from '@utils/http'
import {
  IhospitalListParams,
  IhospitalListResponse,
  IprovinceListType,
  IhospitalShow,
  IdepList,
  IScheduleRuleParams,
  IScheduleRulesResponse,
  iScheduleListType,
  Status,
} from './model/hospitalListTypes'

// 获取医院列表数据的函数
export function reqGetHospitalList({
  page,
  pageSize,
  hosname,
  hoscode,
  provinceCode,
  cityCode,
  districtCode,
  status,
  hostype,
}: IhospitalListParams) {
  return request.get<any, IhospitalListResponse>(
    `/admin/hosp/hospital/${page}/${pageSize}`,
    {
      params: {
        hosname,
        hoscode,
        provinceCode,
        cityCode,
        districtCode,
        status,
        hostype,
      },
    }
  )
}

// 获取省数据的函数
export function reqProvince(dictCode = 'province') {
  return request.get<any, IprovinceListType>(
    `/admin/cmn/dict/findByDictCode/${dictCode}`
  )
}

// 获取市,区数据的函数
export function reqCityOrdistrict(parentId: string) {
  return request.get<any, IprovinceListType>(
    `/admin/cmn/dict/findByParentId/${parentId}`
  )
}

// 获取医院详情的函数
export function reqHospitalShow(id: string) {
  return request.get<any, IhospitalShow>(`/admin/hosp/hospital/show/${id}`)
}

// 获取指定医院所有科室数据
export function reqDepartments(hoscode: string) {
  return request.get<any, IdepList>(`/admin/hosp/department/${hoscode}`)
}

// 获取排班规则的函数
export function reqScheduleRules({
  page,
  pageSize,
  hoscode,
  depcode,
}: IScheduleRuleParams) {
  return request.get<any, IScheduleRulesResponse>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${pageSize}/${hoscode}/${depcode}`
  )
}

// 获取排班列表数据的函数

export function reqScheduleList(
  hoscode: string,
  depcode: string,
  workDate: string
) {
  return request.get<any, iScheduleListType>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  )
}

// 更新医院状态的函数
export function reqUpdateStatus(id: string, status: Status) {
  return request.get<any, null>(
    `/admin/hosp/hospital/updateStatus/${id}/${status}`
  )
}
